from google.appengine.ext import ndb
import datetime

# This is not used at the moment, as we use memcache only sessions.
# I'll use it later
#
# class Sessions(ndb.Model):
#     sid = ndb.StringProperty()
#     email = ndb.StringProperty()
#     ip = ndb.StringProperty()
#     expires = ndb.DateTimeProperty()
#     verified = ndb.BooleanProperty()

class Users(ndb.Model):
    email = ndb.StringProperty()
    name = ndb.StringProperty()
    password = ndb.StringProperty()
    role = ndb.PickleProperty()
    verified = ndb.BooleanProperty()
    vcode = ndb.StringProperty()

    def add_role(self,role):
        self.role.append(role)
    
    def strip_role(self,role):
        self.role.remove(role)
    
class PasswordResets(ndb.Model):
    code = ndb.StringProperty()
    email = ndb.StringProperty()

class Places(ndb.Model):
    location = ndb.GeoPt
    name = ndb.StringProperty()
    city = ndb.StringProperty()
    street = ndb.StringProperty()
    streetnumber = ndb.StringProperty()